package com.gxa.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.stu.entity.pojo.TbManager;
import com.gxa.stu.service.TbManagerService;
import com.gxa.user.mapper.TbManagerMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * <p>
 * 员工详情表 服务实现类
 * </p>
 *
 * @author gxa
 * @since 2022-11-03
 */
@Service
public class TbManagerServiceImpl extends ServiceImpl<TbManagerMapper, TbManager> implements TbManagerService {

    @Autowired
    private TbManagerMapper tbManagerMapper;

    @Override
    public TbManager selectByNum(String mgrNum) {
        LambdaQueryWrapper<TbManager> tbManagerLambdaQueryWrapper = Wrappers.lambdaQuery(TbManager.class);
        tbManagerLambdaQueryWrapper.eq(TbManager::getMgrNum,mgrNum);
        return tbManagerMapper.selectOne(tbManagerLambdaQueryWrapper);
    }

    @Override
    public boolean updateManager(TbManager tbManager) {
        LambdaUpdateWrapper<TbManager> tbManagerLambdaUpdateWrapper = Wrappers.lambdaUpdate(TbManager.class);
        tbManagerLambdaUpdateWrapper.eq(TbManager::getMgrNum,tbManager.getMgrNum());
        int update = tbManagerMapper.update(tbManager, tbManagerLambdaUpdateWrapper);
        return update>0;
    }
}
